/*
 * @Author: li bo
 * @Date: 2025/07/09 14:44:22
 * @LastEditors: li bo
 * @Description: "歌词模型"
 */
module.exports = (sequelize, Sequelize) => {
    return sequelize.define("lyrics", {
        id: {
            type: Sequelize.UUID,
            notNull: true,
            primaryKey: true,
            comment: '唯一标识',
            defaultValue: Sequelize.UUIDV4,
        },
        songId: {
            type: Sequelize.STRING(100),
            allowNull: false,
            comment: '关联歌曲id',
            field: 'song_id',
        },
        language: {
            type: Sequelize.STRING(2),
            allowNull: false,
            comment: '歌词语言(ISO 639-1)',
            defaultValue: 'zh',
        },
        format: {
            type: Sequelize.ENUM('lrc', 'srt', 'txt', 'json'),
            allowNull: false,
            comment: '歌词格式',
            defaultValue: 'lrc',
        },
        filePath: {
            type: Sequelize.STRING(255),
            allowNull: false,
            comment: '歌词文件存储路径'
        },
        fileSize: {
            type: Sequelize.INTEGER,
            allowNull: false,
            comment: '歌词文件大小(字节)'
        }
    }, {
        tableName: 'lyrics',
        comment: '歌词元数据表',
        indexes: [
            {
                unique: true, // 唯一索引
                fields: ['song_id', 'language'] // 联合索引

            },
            {
                fields: ['language']
            }
        ]
    })
}